<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="zdy.web.servlet.HelloWorld" %>
<%@ page import="zdy.web.bean.User" %>
 <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()
		+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<b>
path=request.getContextPath()<br>:<%=path %><br>
basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"<br>
:<%=basePath %>
<br></b>

<p>如何正确的访问 servlet 路径</p>

<ul>
<li><a href="s/hello" target="_blank"> 访问servlet (s/hello) </a></li>
<li><a href="/s/hello" target="_blank"> 访问servlet(/s/hello)</a></li>
<li><a href="web1/s/hello" target="_blank"> 访问servlet(web1/s/hello)</a></li>
<li><a href="/web1/s/hello" target="_blank"> 访问servlet(/web1/s/hello)</a></li>
<li><a href="<%=basePath %>s/hello" target="_blank"> 访问servlet (<\%basePaths%>s/hello) </a></li>
<hr>
<li><a href="callservlet.jsp" target="_blank"> 跳转到servlet</a></li>
<p>import 自定义的bean<br>
  <%
  User u=new User();
  u.setName("xh");
  out.println("u.getName()='"+u.getName()+"'");
  %>
</p>

<p>import 自定义的servlet<br>
  <%
  HelloWorld h=new HelloWorld();
  
  out.println("h.toString()='"+h.toString()+"'");
  %>
</p>

</ul>

</body>
</html>